﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace System.Web.Mvc.Html
{
    public static class DatePickerHelper
    {
        public static string DatePicker(this HtmlHelper htmlHelper, string id, string name, string value)
        {
            StringBuilder sBuilder = new StringBuilder();
            sBuilder.AppendLine("<script language=\"javascript\" type=\"text/javascript\">");
            sBuilder.AppendLine("$(function () {");
            sBuilder.AppendLine("$(\"#" + id + "\").datepicker({");
            sBuilder.AppendLine("showOn: \"button\",");
            sBuilder.AppendLine("buttonImage: \"/Content/images/icon-calendar.gif\",");
            sBuilder.AppendLine("dateFormat: 'dd/mm/yy',");
            sBuilder.AppendLine("buttonImageOnly: true");
            sBuilder.AppendLine(" });");
            sBuilder.AppendLine("});");
            sBuilder.AppendLine("</script>");

            sBuilder.AppendLine("<input type=\"text\" value=\"" + value + "\" id=\"" + id + "\" name=\""+name+"\" class=\"SmallTextBox\" />");
            return sBuilder.ToString();
        }
    }
}